package com.yisu.expressway.onedollar.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.yisu.expressway.R;

import java.util.ArrayList;
import java.util.List;

public class NumGridListAdapter extends BaseAdapter  {

	private Context mContext;
	private List<String> mDataList = new ArrayList<>();

	public NumGridListAdapter(Context context, List<String> data) {
		mContext = context;
		mDataList = data;
	}

	@Override
	public int getCount() {
		return mDataList == null ? 0 : mDataList.size();
	}

	@Override
	public String getItem(int position) {
		return mDataList == null ? null : mDataList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context
				.LAYOUT_INFLATER_SERVICE);
			convertView = layoutInflater.inflate(R.layout.grid_item_num, null);
			holder.textView = (TextView) convertView.findViewById(R.id.tv_num);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		String item = getItem(position);
		if (!TextUtils.isEmpty(item)){
			holder.textView.setText(item);
		}

		return convertView;
	}
	public class ViewHolder {
		public TextView textView;
	}
}
